# -*- coding:utf-8 -*-
"""
@Time : 2021/1/9 16:15
@Author: langengel
@Des: 系统公共
"""
from fastapi import Request

from Authorization.auth import create_access_token
from config.security import ACCESS_TOKEN_EXPIRE_MINUTES
from saas.response.BaseResponse import success


async def refresh_token(req: Request):

    token_data = req.state.token_data
    # 生成jwt token
    access_token = create_access_token(data=token_data)

    return success(
        data={
            "access_token": access_token,
            "expires_in": ACCESS_TOKEN_EXPIRE_MINUTES * 60,
            "token_type": "bearer",
        },
        msg="refresh_token"

    )
